<!--分类字典管理-->
<template>
  <div id="upmsCategoryDict" class="app-container">
    <div class="common-tabs-1">
      <el-tabs v-model="type" class="common-tabs">
        <el-tab-pane v-for="item in categoryTypes" :key="item.dataDictItemCode" :label="item.dataDictItemName" :name="item.dataDictItemCode" />
      </el-tabs>
      <el-dropdown :hide-on-click="false" class="tools">
        <span class="el-dropdown-link common-cursor">
          <i class="el-icon-arrow-down el-icon--right" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="handleCreate">新增</el-dropdown-item>
          <el-dropdown-item @click.native="initConfigType">刷新</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>

    <category-dict-editor :type="type" />
    <data-dict-editor-dialog ref="dataDictEditorDialog" />
  </div>
</template>

<script>
export default {
  components: {},

  data() {
    return {
      type: '',
      categoryTypes: []
    }
  },
  watch: {
  },
  created() {
    this.initConfigType()
  },
  methods: {
    async initConfigType() {
      const response = await this.$store.dispatch('findDataDictItemByCode', 'dataDictType')
      this.categoryTypes = response
      if (this.categoryTypes.length > 0) {
        this.type = this.categoryTypes[0].dataDictItemCode
      }
    },
    handleCreate() {
      this.$refs.dataDictEditorDialog.init('dataDictType', '分类')
    }

  }
}
</script>
<style lang="scss" >
</style>
